<?php

namespace Admin\Controller;


/**
 * 后台展位管理页面控制器
 * 主要获取展位管理页面聚合数据
 */
class BoothmanagementController extends AdminController {
    
	//展位管理
	public function booth_management(){
        $where = array();
        $where  = array('active' => 1);
		$boothname=I('boothname');
        //if(isset($_GET['boothname'])){
        //    $where['boothname']    =   array('like', '%'.(string)I('boothname').'%');
        //}
		if(is_numeric($boothname)){
			$where['id|boothname']=array(intval($boothname),array('like','%'.$boothname.'%'),'_multi'=>true);//'_multi'=>true表示多条件匹配
		}else{
		    $where['boothname']=array('like','%'.(string)$boothname.'%');
		}
		
		$lists = $this->lists('Booth_info',$where,'id ');
		//$lists  = D('Booth_info')->where($where)->order('bid asc')->select();//查询语句
    	$this->assign('boothmanagement',$lists);
	 
	    $this->display();
	}

	//展位审核
    public function booth_review(){
		$where=array();
		$boothname=I('boothname');//此处一下代码实现多条件查询
		//$where=array('active'=>0);
		$where=array('active'=>0);
		if(is_numeric($boothname)){
			$where['id|boothname']=array(intval($boothname),array('like','%'.$boothname.'%'),'_multi'=>true);//'_multi'=>true表示多条件匹配
		}else{
		    $where['boothname']=array('like','%'.(string)$boothname.'%');
		}
		$list=$this->lists('Booth_info',$where,'id ');
		$this->assign('boothreview',$list);
	    $this->display();
	}

	//删除
	 public function del(){
       $id = array_unique((array)I('id',0));

        if ( empty($id) ) {
            $this->error('请选择要操作的数据!');
        }

        $map = array('id' => array('in', $id) );
        if(M('Booth_info')->where($map)->delete()){
           
            $this->success('删除成功');
        } else {
            $this->error('删除失败！');
        }
    }


    //屏蔽，开启，删除
    public function changestatus($method=null){
        $id=array_unique((array)I('id',0));
        $id=is_array($id) ? implode(',',$id) : $id;
        if(empty($id)){
            $this->error('请选择要操作的数据');
        }
        $where['id']=array('in',$id);
        switch(strtolower($method)){
            case 'forbidbooth':
              $this->forbid('Booth_info',$where);
              break;
            case 'resumebooth':
              $this->resume('Booth_info',$where);
              break;
            case 'deletebooth':
              $this->delete('Booth_info',$where);
              break;
            default:
              $this->error('参数非法');
        }
    }
	//审核操作，通过 写死我了
	public function reviewok(){
		 $id = array_unique((array)I('id',0));
		 $id=is_array($id) ? implode(',',$id) : $id;
		 //var_dump($id);exit;
	     $info=M('Booth_info');
		 $info->active='1';
		 $info->activedeclare='审核通过';
		 $info->where('id'.'='.$id)->save();
		 if($info){
			 
                    $this->success('审核成功',U('Boothmanagement/booth_review'));
         } else {
                    $this->error('审核失败',U('Boothmanagement/booth_review'));
                }


	   }

	   public function reviewrefuse(){
		   $id = array_unique((array)I('id',0));
		   $id=is_array($id) ? implode(',',$id) : $id;
		   $info=M('Booth_info');
		   $info->active='-1';
		   $info->activedeclare='审核没通过';
		   $info->where('id'.'='.$id)->save();
		   if($info){
		         $this->success('审核成功',U('Boothmanagement/booth_review'));
           } else {
                 $this->error('审核失败',U('Boothmanagement/booth_review'));
           }

	   
	   }




}




?>